<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
require_once __DIR__ . "/Common.php";
$bucket = Common::getBucketName();
$ossClient = Common::getOssClient();
if(is_null($ossClient)) {
    exit(1);
}
$ossClient->putBucketLogging($bucket, $bucket, "access.log", []);
Common::println("bucket " . $bucket . " lifecycleConfig created");
$loggingConfig = $ossClient->getBucketLogging($bucket, []);
Common::println("bucket " . $bucket . " lifecycleConfig fetched:" . $loggingConfig->serializeToXml());
$loggingConfig = $ossClient->getBucketLogging($bucket, []);
Common::println("bucket " . $bucket . " lifecycleConfig deleted");
putBucketLogging($ossClient, $bucket);
getBucketLogging($ossClient, $bucket);
deleteBucketLogging($ossClient, $bucket);
getBucketLogging($ossClient, $bucket);
function putBucketLogging($ossClient, $bucket)
{
    $option = [];
    $targetBucket = $bucket;
    $targetPrefix = "access.log";
    try {
        $ossClient->putBucketLogging($bucket, $targetBucket, $targetPrefix, $option);
    } catch (OSS\Core\OssException $e) {
        printf("putBucketLogging: FAILED\n");
        printf($e->getMessage() . "\n");
        return NULL;
    }
    echo "putBucketLogging: OK\n";
}
function getBucketLogging($ossClient, $bucket)
{
    $loggingConfig = NULL;
    $options = [];
    try {
        $loggingConfig = $ossClient->getBucketLogging($bucket, $options);
    } catch (OSS\Core\OssException $e) {
        printf("getBucketLogging: FAILED\n");
        printf($e->getMessage() . "\n");
        return NULL;
    }
    echo "getBucketLogging: OK\n";
    echo $loggingConfig->serializeToXml() . "\n";
}
function deleteBucketLogging($ossClient, $bucket)
{
    try {
        $ossClient->deleteBucketLogging($bucket);
    } catch (OSS\Core\OssException $e) {
        printf("deleteBucketLogging: FAILED\n");
        printf($e->getMessage() . "\n");
        return NULL;
    }
    echo "deleteBucketLogging: OK\n";
}

?>